﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Soufun.DAL;
using Soufun.Model;
using System.Threading;

namespace Soufun
{
    public partial class UserForm : DevExpress.XtraEditors.XtraForm
    {
        public UserForm()
        {
            InitializeComponent();
        }
        private void UserForm_Load(object sender, EventArgs e)
        {
            Thread t = new Thread(BindGrid) { IsBackground = true };
            t.Start();
        }
        private DUser _dUser = new DUser();

        private void BindGrid()
        {
            try
            {
                DataSet ds = _dUser.GetList("");
                if (ds == null || ds.Tables.Count == 0)
                {
                    XtraMessageBox.Show("未能获取到用户列表，请检查数据库是否正常！");
                    return;
                }
                BeginInvoke(new MethodInvoker(() =>
                    {
                        gridControl1.DataSource = ds.Tables[0];
                        gridView1.GroupPanelText = "当前共" +
                                                   ds.Tables[0].Rows.Count + "个用户";
                    }));
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("加载用户列表出现异常，请检测数据库连接是否正常！ 异常信息："
                                    + Environment.NewLine+ex.Message);
            }
        }

       
    }
}